#! /bin/sh
#
# Miredo client hook script for BSD

IFCONFIG=/sbin/ifconfig
ROUTE=/sbin/route

if ! test -x "$IFCONFIG"; then
        echo "$0: $IFCONFIG is required!" >&2
        exit 1
fi

if ! test -x "$ROUTE"; then
        echo "$0: $ROUTE is required!" >&2
        exit 1
fi

case "$STATE" in
	up)
		"$IFCONFIG" "$IFACE" up
		"$IFCONFIG" "$IFACE" inet6 "${LLADDRESS}/64"
		"$IFCONFIG" "$IFACE" inet6 "${ADDRESS}/128"
		"$ROUTE" delete -inet6 default
		"$ROUTE" add -inet6 default -iface "$IFACE"
		;;
	down)
		"$IFCONFIG" "$IFACE" down
		;;
	destroy)
		"$IFCONFIG" "$IFACE" destroy
esac

# TODO: MacOS X should probably get its fork of the script
# MacOS X DNS resolver must be reloaded when IPv6 availability changes
#/sbin/killall -HUP something

exit 0
